﻿Public Class frmDernieresValidations
    Private szSQL As String
    Private rs As ADODB.Recordset

    Private Sub frmValiderExport_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ' init date dernière exportation comptable
        TE_DERN_EXPORT.Text = getDateDerniere("export", 6)
        ' init date dernière validation B de l'agence
        InitComboAgences(CB_Agences)
        CB_Agences.SelectedIndex = gUserAgence - 1
        TE_DERN_PLANNING.Text = getDateDerniere("validation", CB_Agences.SelectedIndex + 1)

        TE_NEW_EXPORT.Value = Format(Now, "yyyy/MM/dd")
        TE_NEW_PLANNING.Value = Format(Now, "yyyy/MM/dd")

    End Sub

    Private Sub CB_Agences_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CB_Agences.SelectedIndexChanged
        TE_DERN_PLANNING.Text = getDateDerniere("validation", CB_Agences.SelectedIndex + 1)
    End Sub

    Private Sub BO_PLANNINGB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BO_PLANNINGB.Click
        ' mémoriser la date de dernière validation
        szSQL = "CALL spUPD_LAST_VALIDATION(" & CB_Agences.SelectedIndex + 1 & ",'" & Format(TE_NEW_PLANNING.Value, "yyyy/MM/dd") & "')"
        ExecQuery(ctDSN_AEM, szSQL)
        Me.Close()
    End Sub

    Private Sub BO_COMPTABLE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BO_COMPTABLE.Click
        ' mémoriser la date de dernière exportation
        szSQL = "CALL spUPD_LAST_EXPORTATION('" & Format(TE_NEW_EXPORT.Value, "yyyy/MM/dd") & "')"
        ExecQuery(ctDSN_AEM, szSQL)
        Me.Close()
    End Sub
End Class